﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using CourseArraging.Common; 
using System.Drawing;
using System.Windows.Forms;
using System.Data;
using CourseArraging.Frm.bbxx;

namespace CourseArraging.Frm.jcxx
{
    /// <summary>
    /// 版权所有
    /// 石世特@温州医学院 sst330381@gmail.com
    /// </summary> 
    public class FrmJcxxGrade : FrmJcxxBase
    {
        // Fields 
        private IContainer components = null;
        protected static FrmJcxxGrade instance;

        DataTable bbDt = new DataTable();

        // Methods
        public FrmJcxxGrade()
        {
            this.InitializeComponent();
            this.showData();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void frm_reflist()
        {
            this.showData();
        }

        public static FrmJcxxGrade GetInstance()
        {
            if ((instance == null) || instance.IsDisposed)
            {
                instance = new FrmJcxxGrade();
                instance.MdiParent = GlobalVar.frmMain;
            }
            instance.BringToFront();
            return instance;
        }

        private void InitializeComponent()
        {
            base.SuspendLayout();
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x148, 0x184);
            base.Name = "FrmJcxxGrade";
            this.Text = "年级信息";
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        public override void newForm(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView view = (DataGridView)sender;
            FrmInfoGrade grade = new FrmInfoGrade(int.Parse(view.Rows[e.RowIndex].Cells[0].Value.ToString()), view.Rows[e.RowIndex].Cells[1].Value.ToString());
            grade.reflist += new FrmInfoGrade.refreshlist(this.frm_reflist);
            grade.ShowDialog();
        }

        public override void showData()
        {
            base.dataGridView1.DataSource = base.otherDao.getGradeInfo4table(0, null) ;
        }

        public override void tsb_new_fun()
        {
            FrmInfoGrade frm = new FrmInfoGrade();
            frm.reflist+=new FrmInfoGrade.refreshlist(frm_reflist);
            frm.ShowDialog();
        }



        public override void tsb_print_fun()
        {
            bbDt = base.otherDao.getGradeInfo4table(0, null);
            FrmJcxxBb frmJcxxBb = new FrmJcxxBb(bbDt);
            frmJcxxBb.ShowDialog();
        }

        //public override void tsb_save_fun()
        //{
        //    if (this.basicDao.getEqualGrade(base.tstxt_item.Text.Trim()))
        //    {
        //        MessageBox.Show("已经存在该项, 请重新填写 ! ");
        //    }
        //    else
        //    {
        //        this.basicDao.addGradeInfo(base.tstxt_item.Text.Trim());
        //        MessageBox.Show("添加成功 ! ");
        //        this.showData();
        //    }
        //}
    }

 

}
